<template>
  <el-dialog
    v-el-drag-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="100px">
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="注册时间:" prop="addTime">
              <span>{{dataForm.addTime}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="营业时间:" prop="msn">
              <span>{{dataForm.msn}}</span>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="会员名称:" prop="trueName">
              <span>{{dataForm.trueName}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="会员账号:" prop="username">
              <span>{{dataForm.username}}</span>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="会员负责人:" prop="realName">
              <span>{{dataForm.realName}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="会员Mobile:" prop="mobile">
              <span>{{dataForm.mobile}}</span>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="会员主图:" prop="mainImgSrc">
              <el-upload
              action=""
              disabled="true"
              list-type="picture-card"
              :file-list="dataForm.mainImgSrc"
              :on-preview="handlePreview">
              <i class="el-icon-plus"></i>
              </el-upload>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="营业证件:" prop="licensePic">
              <el-upload
              action=""
              disabled="true"
              list-type="picture-card"
              :file-list="dataForm.licensePic"
              :on-preview="handlePreview1">
              <i class="el-icon-plus"></i>
              </el-upload>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="审核意见:" prop="checkComment">
              <span>{{dataForm.checkComment}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="会员地址:" prop="address">
              <span>{{dataForm.address}}</span>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="会员描述:" prop="description">
              <span>{{dataForm.description}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="现金券余额:" prop="integral">
              <span>{{dataForm.integral}}</span>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="推广余额:" prop="commissionMoney">
              <span>{{dataForm.commissionMoney}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="总金额/元:" prop="balanceMoney">
              <span>{{dataForm.balanceMoney}}</span>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="未提现/元:" prop="notExtract">
              <span>{{dataForm.notExtract}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="上级名称:" prop="paNUserTrueName">
              <span>{{dataForm.paNUserTrueName}}</span>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="上级账号:" prop="paNUserName">
              <span>{{dataForm.paNUserName}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="上级负责人:" prop="paRealName">
              <span>{{dataForm.paRealName}}</span>
            </el-form-item>
          </el-col>
      </el-row>
      <el-row :gutter="20">
          <el-col :span="10">
            <el-form-item label="会员类型:" prop="userType">
              <el-select v-model="dataForm.userType" placeholder="会员类型">
                <el-option
                  v-for="item in dataForm.paNUserTypeOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                  disabled="true">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="上级类型:" prop="paNUserType">
              <el-select v-model="dataForm.paNUserType" placeholder="上级类型">
                <el-option
                  v-for="item in dataForm.paNUserTypeOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                  disabled="true">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
      </el-row>
    <!-- <el-form-item label="会员类型" prop="userType">
      <el-select v-model="dataForm.userType" placeholder="会员类型">
          <el-option
            v-for="item in dataForm.paNUserTypeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
            disabled="true">
          </el-option>
        </el-select>
    </el-form-item>
    <el-form-item label="上级类型" prop="paNUserType">
      <el-select v-model="dataForm.paNUserType" placeholder="上级类型">
          <el-option
            v-for="item in dataForm.paNUserTypeOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
            disabled="true">
          </el-option>
        </el-select>
    </el-form-item> -->
    </el-form>
    <!-- <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span> -->
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        classList: [],
        dialogImageUrl: '',
        dialogVisible: false,
        dialogImageUrl1: '',
        dialogVisible1: false,
        dataForm: {
          addTime: '',
          msn: '',
          trueName: '',
          username: '',
          realName: '',
          userType: '',
          mobile: '',
          checkComment: '',
          address: '',
          description: '',
          integral: '',
          commissionMoney: '',
          balanceMoney: '',
          notExtract: '',
          yesExtract: '',
          paNUserTrueName: '',
          paNUserName: '',
          paRealName: '',
          paNUserType: '',
          mainImgSrc: [],
          licensePic: [],
          paNUserTypeOptions: [{
            value: 0,
            label: '未知'
          }, {
            value: 1,
            label: '区域运营商'
          }, {
            value: 2,
            label: '普通联盟店'
          }, {
            value: 3,
            label: '消费者'
          }, {
            value: 4,
            label: 'VIP会员'
          }, {
            value: 5,
            label: '中级版联盟店'
          }, {
            value: 6,
            label: '高级版联盟店'
          }, {
            value: 7,
            label: '城市合伙人'
          }, {
            value: 8,
            label: '城市合伙人联盟店'
          }]
        },
        dataRule: {
          className: [
            { required: true, message: '分类名称不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
        // 图片预览
      handlePreview (file) {
        this.dialogImageUrl = file.url
        this.dialogVisible = true
      },
      handlePreview1 (file) {
        this.dialogImageUrl1 = file.url
        this.dialogVisible1 = true
      },
      init (id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/user/business/getBusinessCashWithdrawal/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.addTime = data.data.addTime
                this.dataForm.msn = data.data.msn
                this.dataForm.trueName = data.data.trueName
                this.dataForm.username = data.data.username
                this.dataForm.realName = data.data.realName
                this.dataForm.userType = data.data.userType
                this.dataForm.mobile = data.data.mobile
                var mainpic = data.data.mainImgSrc
                if (mainpic != null) {
                  this.dataForm.mainImgSrc.push({name: 'tupian', url: mainpic})
                }
                var pic = data.data.licensePic
                if (pic != null) {
                  this.dataForm.licensePic.push({name: 'tupian', url: pic})
                }
                this.dataForm.checkComment = data.data.checkComment
                this.dataForm.address = data.data.address
                this.dataForm.description = data.data.description
                this.dataForm.integral = data.data.integral
                this.dataForm.commissionMoney = data.data.commissionMoney
                this.dataForm.balanceMoney = data.data.balanceMoney
                this.dataForm.notExtract = data.data.notExtract
                this.dataForm.yesExtract = data.data.yesExtract
                this.dataForm.paNUserTrueName = data.data.paNUserTrueName
                this.dataForm.paNUserName = data.data.paNUserName
                this.dataForm.paRealName = data.data.paRealName
                this.dataForm.paNUserType = data.data.paNUserType
              }
            })
          }
        })
      }
      // 表单提交
    //   dataFormSubmit () {
    //     this.$refs['dataForm'].validate((valid) => {
    //     //   console.log(this.dataForm.id)
    //     //   console.log(this.dataForm.className)
    //       if (valid) {
    //         this.$http({
    //           url: this.$http.adornUrl(`/business/shoppinguser/updateByIdOrInformation`),
    //           method: 'post',
    //           data: this.$http.adornData({
    //             'id': this.dataForm.id || undefined,
    //             'classname': this.dataForm.className
    //           })
    //         }).then(({data}) => {
    //           if (data && data.code === 0) {
    //             this.$message({
    //               message: '操作成功',
    //               type: 'success',
    //               duration: 1500,
    //               onClose: () => {
    //                 this.visible = false
    //                 this.$emit('refreshDataList')
    //               }
    //             })
    //           } else {
    //             this.$message.error(data.msg)
    //           }
    //         })
    //       }
    //     })
    //   }
    }
  }
</script>
